using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class RegisterMap : EntityTypeConfiguration<Register>
    {
        public RegisterMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(30);

            this.Property(t => t.MESSAGE)
                .HasMaxLength(254);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.Location)
                .HasMaxLength(3);

            // Table & Column Mappings
            this.ToTable("Register");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.StoreNum).HasColumnName("StoreNum");
            this.Property(t => t.MESSAGE).HasColumnName("MESSAGE");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.cstctrid).HasColumnName("cstctrid");
            this.Property(t => t.AllowNegONHAND).HasColumnName("AllowNegONHAND");
            this.Property(t => t.Location).HasColumnName("Location");
            this.Property(t => t.ReceiptPrinter).HasColumnName("ReceiptPrinter");
            this.Property(t => t.InvoicePrinter).HasColumnName("InvoicePrinter");
            this.Property(t => t.DocType).HasColumnName("DocType");
            this.Property(t => t.CustType).HasColumnName("CustType");
            this.Property(t => t.ShowSaleTypeDlg).HasColumnName("ShowSaleTypeDlg");
            this.Property(t => t.CashierMode).HasColumnName("CashierMode");
            this.Property(t => t.Invoicemode).HasColumnName("Invoicemode");

            // Relationships
            this.HasRequired(t => t.Cstctr)
                .WithMany(t => t.Registers)
                .HasForeignKey(d => d.cstctrid);
            this.HasRequired(t => t.Store)
                .WithMany(t => t.Registers)
                .HasForeignKey(d => d.StoreNum);

        }
    }
}
